home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
win
/
afxvbx.zip
/
AFXVBX.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-15
|
6KB
|
134 lines
/*------------------------------------------------------------------------------*
| |
| File Name: AFXVBX.CPP |
| |
| Description: This file contains all the functions for the AFXDLL used by |
| its calling application APP.EXE |
| |
| History: Date Author Comment |
| 05/23/93 Pran Punniamoorthy Created with the help |
| of John Seghers |
| |
*------------------------------------------------------------------------------*/
#include <afxwin.h>
#include <afxext.h>
#include <afxdllx.h> // standard MFC Extension DLL routines
#include "afxdllres.h" // The DLL resource definitions
#include "afxvbx.h" // The DLL class definitions
HINSTANCE hInstDLL; // Global copy of the DLL instance handle
/////////////////////////////////////////////////////////////////////////////
// Initialization of MFC Extension DLL
static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };
extern "C" int CALLBACK LibMain(HINSTANCE hInstance, WORD, WORD, LPSTR)
{
// Extension DLL one-time initialization - do not allocate memory here,
// use the TRACE or ASSERT macros or call MessageBox
AfxInitExtensionModule(extensionDLL, hInstance);
hInstDLL = hInstance;
return 1;
}
/////////////////////////////////////////////////////////////////////////////
// Exported DLL initialization is run in context of running application
extern "C" extern void _export WINAPI InitAfxVbx()
{
new CDynLinkLibrary(extensionDLL);
CWinApp* pApp = AfxGetApp();
ASSERT(pApp != NULL);
pApp->m_pMainWnd = new CMainWindow(); // Create MainWindow object
pApp->m_pMainWnd->ShowWindow(SW_SHOWNORMAL);
pApp->m_pMainWnd->UpdateWindow();
WNDCLASS wndClass;
if(::GetClassInfo(hInstDLL,"VBControl",&wndClass)==0) // Get the wndclass struct. of class VBControl
{
VERIFY(::GetClassInfo(AfxGetInstanceHandle(),"VBControl",&wndClass));
wndClass.hInstance = hInstDLL; // Change the instance handle so it is that of the DLL and not the App.
VERIFY(::RegisterClass(&wndClass)); // Register the class
}
}
/*------------------------------------------------------------------------------*
| Constructor For class CMainWindow |
| |
| Description: In the constructor, the main window for the application is |
| created. |
| |
| Parameters : none |
| |
| Returns : void |
| |
*------------------------------------------------------------------------------*/
CMainWindow::CMainWindow()
{
Create( NULL, "VBX Control resource of AFXDLL",
WS_OVERLAPPEDWINDOW, rectDefault, NULL, MAKEINTRESOURCE(IDR_MENU1) );
}
/*------------------------------------------------------------------------------*
| CMainWindow::OnVBXDialog() |
| |
| Description: This function displays a dialog box that contains a vbx control|
| which is a resource of the DLL. |
| |
| Parameters : none |
| |
| Returns : void |
| |
*------------------------------------------------------------------------------*/
void CMainWindow::OnVBXDialog()
{
CVBXDialog vbxDialog(IDD_DIALOG1);
vbxDialog.DoModal();
}
////////////////////////////// The Message Map for class CMainWindow /////////////////////////
BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd )
ON_COMMAND( ID_DIALOG_DIALOGPRESS, OnVBXDialog )
END_MESSAGE_MAP()
/*------------------------------------------------------------------------------*
| CVBXDialog::OnInitDialog() |
| |
| Description: This function does the necessary function calls to get a vbx |
| control that is part of a dialog that is a resource of a AFXDLL|
| to be displayed correctly. Add your own initialization code |
| below the comment line "Add your initialization code below". |
| |
| Parameters : none |
| |
| Returns : BOOL |
| |
*------------------------------------------------------------------------------*/
BOOL CVBXDialog::OnInitDialog()
{
HINSTANCE hOldInstance = _AfxGetAppData()->appCurrentInstanceHandle;
_AfxGetAppData()->appCurrentInstanceHandle = hInstDLL;
CDialog::OnInitDialog();
_AfxGetAppData()->appCurrentInstanceHandle = hOldInstance;
// Add your initialization code below
return TRUE;
}